<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:replace="top::html" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

<body class="fixed hold-transition skin-blue">
    <div class="wrapper">
        <div th:replace="tophtml::html"></div>
        <div th:replace="left::html"></div>
        <div class="content-wrapper">
			<!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    <span>需求匹配项目</span>
                    <small></small>
                </h1>
                <ol class="breadcrumb">
                    <li th:replace="/demand/showQuery :: section.content-header/ol/li"></li>
                    <li th:if="${customerId}"><a th:href="@{'/project/showDemandMatchedProject?pid='+${demand.pid}+'&customerId='+${customerId}}">需求匹配项目</a></li>
                    <li th:unless="${customerId}"><a th:href="@{'/project/showDemandMatchedProject?pid='+${demand.pid}}">需求匹配项目</a></li>
                </ol>
            </section>

            <section class="content container-fluid">
                <p style="color: red;" th:text="${searchEmpty}"></p>
                <form id="from1" class="form-inline" th:action=" @{/project/searchMatchedProject}" method="get">
                    <input type="hidden" name="pageNo" id="pageNo" />
                    <input type="hidden" name="demandId" th:value="${demand.pid}" />
                    <input type="hidden" th:if="${customerId}" name="customerId" th:value="${customerId}" />
	            	<div style="font-size: 16px;">
		              	<div class="form-group">
		              		<div th:if="${customer}">
								<label>客户名称:</label>
								<a th:href="@{'/customer/customerList?pid='+${customer.pid}}"  th:title="${customer.customerName}" th:text="${#strings.length(customer.customerName)} > 20 ? ${#strings.substring(customer.customerName, 0, 20)}+'...' : ${customer.customerName}"></a>
			            		<a th:href="@{'/customer/hasbeencompared?customerNumber='+${customer.customerNumber}+'&customerId='+${customerId}}" title="客户的所有需求已匹配的项目和专家" style="font-weight: bolder;margin-left: 60px;">已匹配</a>
			                </div>
		              	</div>
			            <br>
		              	<div class="form-group">
							<label>需求名称:</label>
							<a th:href="@{'/demand/showConditionQuery?searchKeyword=D'+${demand.demandNumber}}" th:text="${#strings.length(demand.demandName)} > 20 ? ${#strings.substring(demand.demandName, 0, 20)}+'...' : ${demand.demandName}" th:title="${demand.demandName}">查看详情</a>
		            		<a th:if="${#strings.isEmpty(customerId)}" th:href="@{'/demand/showProjectButtDetail?pid='+${demand.pid}}"  style="font-weight: bolder;margin-left: 60px;">需求已匹配项目</a>
		            		<a th:unless="${#strings.isEmpty(customerId)}" th:href="@{'/demand/showProjectButtDetail?pid='+${demand.pid}+'&customerId='+${customerId}}"  style="font-weight: bolder;margin-left: 60px;">需求已匹配项目</a>
		            		<a th:unless="${#lists.isEmpty(buttedProjectIdList)}" th:href="@{/demand/downButtedProject(demandId=${demand.pid})}" style="font-weight: bolder;margin-left: 60px;">下载</a>
		              	</div>
		             	<br>
		             	<div class="form-group">
							<label>需求类型:</label>
							<span th:title="${demand.demandType}" th:text="${#strings.length(demand.demandType)} > 20 ? ${#strings.substring(demand.demandType, 0, 20)}+'...' : ${demand.demandType}"></span>            			
		             	</div>
		              	<br>
		               	<div class="form-group">
							<label>需求内容:</label>
							<span th:title="${demand.demandContent}" th:text="${#strings.length(demand.demandContent)} > 20 ? ${#strings.substring(demand.demandContent, 0, 20)}+'...' : ${demand.demandContent}"></span>            			
		             	</div>
					</div>   
	                <hr style="height:1px;border:none;border-top:1px solid #a4b1c2;" /> 
                    <div class="form-group">
						<label style="font-weight: lighter;"> 
							<input type="radio" name="demandMatch" checked> 需求匹配项目 
						</label>
						<label style="font-weight: lighter;"> 
							<input type="radio" th:if="${customer}" name="demandMatch" th:value="@{'/person/showDemandMatchedExpert?pid='+${demand.pid}+'&customerId='+${customerId}}"> 
							<input type="radio" th:unless="${customer}" name="demandMatch" th:value="@{'/person/showDemandMatchedExpert?pid='+${demand.pid}}"> 需求匹配专家
						</label>
					</div><br/>
                    <div class="form-group">
                        <input style="width: 500px; display: inline" type="text" class="form-control" placeholder="id或名称或关键字" name="searchKeyword" th:value="${param.searchKeyword}">
                        <button type="submit" class="btn btn-primary" style="margin-left: 40px;">搜索</button>
                       <!--   <button type="reset" style="margin-left: 40px;" class="btn btn-primary">重置</button>-->
                        <input type="button" class="btn btn-primary" value="返回" onclick="window.history.go(-1)" style="margin-left: 40px;">
                    </div><br>
                    <div class="form-group">
                        <label>所属领域</label>
                        <span th:each="rfd : ${researchFieldDictiontryList}">
                            <label style="font-weight: lighter;">
	                            <input type="checkbox" name="researchField" th:value="${rfd.names}" th:text="${rfd.worth}" th:checked="${researchFieldArr != null ? #arrays.contains(researchFieldArr, rfd.names) : false}">
                            </label>
                        </span>
                    </div>
                    <div>
                        <span class="from-group">
                            <label>国内国外</label>
                            <label style="font-weight: lighter;">
	                            <input type="radio" name="domesticOrForeign" id="optionsRadios1" value="0" th:checked="${domesticOrForeign == 0}"> 国内
                            </label>
                            <label style="font-weight: lighter;">
	                            <input type="radio" name="domesticOrForeign" id="optionsRadios2" value="1" th:checked="${domesticOrForeign == 1}"> 国外
                            </label>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="provinceId">
                                <option value="-1">--选择省--</option>
                                <option th:each="list:${provinceDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq province}"></option>
                            </select>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="cityId">
                                <option value="-1">--选择市--</option>
                                <option th:each="list:${cityDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq city}"></option>
                            </select>
                        </span>
                        <span class="form-group form-area">
                            <select class="form-area" id="areaId">
                                <option value="-1">--选择区--</option>
                                <option th:each="list:${areaDictiontryList}" th:value="${list.names}" th:text="${list.worth}" th:selected="${list.names eq district}"></option>
                            </select>
                        </span>
                        <span class="form-group form-country">
                            <select class="form-area">
                                <option value="-1">--选择国家--</option>
                                <option th:each="list:${countryDictiontryList}" th:value="${list.pid}" th:text="${list.worth}" th:selected="${list.pid eq country}"></option>
                            </select>
                        </span>
                    </div>
                </form>
                <div class="box">
                    <div class="box-body"> 
                    <button id="dosubmit" class="btn btn-primary">匹配</button>
                        <table class="table table-bordered">
                            <tbody>
                                <tr>
                                    <th><input id="all" type="checkbox" /></th>
                                    <th>项目id</th>
                                    <th>项目名称</th>
                                    <th>项目类型</th>
                                    <th>项目状态</th>
                                    <th>联系人</th>
                                    <th>匹配</th>
                                </tr>
                                <tr th:each="project : ${pageInfo.list}" th:with="isButted=${not #lists.isEmpty(buttedProjectIdList)} and ${#lists.contains(buttedProjectIdList, project.projectId)}" th:class="${isButted} ? butt-gray">
                                    <td>
                                    	<input type="checkbox" class="matched" th:disabled="${isButted}" 
                                    		th:value="'demandId='+${demand.pid}+'&demandNumber='+${demand.demandNumber}+'&demandName='+${demand.demandName}+'&projectId='+${project.projectId}+'&projectNumber='+${#strings.replace(project.projectNumber, 'R', '')}+'&projectName='+${project.projectName}" />
                                    </td>
                                    <td>
                                    	<a th:href="@{'/project/showDetail?projectId='+${project.projectId}+'&demandId='+${demand.pid}}" th:text="${project.projectNumber}"></a>
                                    </td>
                                    <td th:text="${#strings.length(project.projectName)} > 30 ? ${#strings.substring(project.projectName, 0, 30)}+'...' : ${project.projectName}" th:title="${project.projectName}">飞行汽车</td>
                                    <td th:text="${project.projectType}">类型</td>
                                    <td th:text="${project.projectStatus}">状态</td>
                                    <td>
                                        <a th:if="${project.projectContactId} and ${project.projectContactId} != 'null'" th:href="@{'/project/showUpdateContact?projectContactId='+${project.projectContactId}}" th:text="${project.projectContactName}">联系人</a>
                                    </td>
                                    <td>
                                    	<a href="javascript:void(0);" th:class="${not isButted} ? singleMatch">匹配</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <p style="color: red;" th:text="${notHolderUpdate}"></p>
                        <p style="color: red;" th:text="${projectContactExists}"></p>
                        <p style="color: red;" th:text="${projectContactNotExists}"></p>
                        <div th:replace="page1::html"></div>
                    </div>
                </div>
            </section>
        </div>
        <div th:replace="footer::html"></div>
        <div class="control-sidebar-bg"></div>
    </div>
    <div th:replace="bottom::html"></div>
    <script type="text/javascript" th:inline="javascript">
        matchButt([[@{/project/demandMatchProject}]]);
        $("a.singleMatch").one("click", function() {
        	$(this).closest("tr").find(":checkbox").prop("checked", true);
        	matching([[@{/project/demandMatchProject}]]);
        });
    </script>
</body>

</html>